//////////////////////////////////////////
// Make Table S5
//////////////////////////////////////////


gl path "~/Dropbox/CovidTurnout/replication"

use "$path/original_data/analysis_file.dta", clear
keep if inlist(age, 64, 65)
keep if inlist(year, 2020, 2016, 2012)

* Turnout
reghdfe voted age65_2020 [fw=obs], a(year age) vce(robust)
local b1 = _b[age65_2020]
local se1 = _se[age65_2020]
local n1 = e(N)
local c1 = _b[_cons]

reghdfe voted age65_2020 [fw=obs], a(i.c#i.year i.c#i.age) vce(robust)
local b2 = _b[age65_2020]
local se2 = _se[age65_2020]
local n2 = e(N)

* Absentee 
reghdfe absentee age65_2020 [fw=obs], a(year age) vce(robust)
local b3 = _b[age65_2020]
local se3 = _se[age65_2020]
local n3 = e(N)

reghdfe absentee age65_2020 [fw=obs], a(i.c#i.year i.c#i.age) vce(robust)
local b4 = _b[age65_2020]
local se4 = _se[age65_2020]
local n4 = e(N)

* Early Voting
reghdfe early age65_2020 [fw=obs], a(year age) vce(robust)
local b5 = _b[age65_2020]
local se5 = _se[age65_2020]
local n5 = e(N)

reghdfe early age65_2020 [fw=obs], a(i.c#i.year i.c#i.age) vce(robust)
local b6 = _b[age65_2020]
local se6 = _se[age65_2020]
local n6 = e(N)

* Election Day
reghdfe precinct age65_2020 [fw=obs], a(i.c#i.year i.c#i.age) vce(robust)
local b7 = _b[age65_2020]
local se7 = _se[age65_2020]
local n7 = e(N)

reghdfe precinct age65_2020 [fw=obs], a(i.c#i.year i.c#i.age) vce(robust)
local b8 = _b[age65_2020]
local se8 = _se[age65_2020]
local n8 = e(N)


quietly {
	cap log close
	set linesize 255

	log using "$path/output/did_table.tex", text replace
	
	noisily dis "\begin{table}[t]"
	noisily dis "\centering"
	noisily dis "\caption{\textbf{Effect of No-Excuse Absentee Voting on Turnout and Vote Mode, Texas Presidential General Elections, 2012-2020.} \label{tab:did_texas}}"
	noisily dis "\resizebox{1\textwidth}{!}{"
	noisily dis "\begin{tabular}{lcccccccc}"
	noisily dis "\toprule \toprule"
	noisily dis " & \multicolumn{2}{c}{\textbf{Overall Turnout}} & \multicolumn{2}{c}{\textbf{Absentee Voting}} & \multicolumn{2}{c}{\textbf{Early In-Person}} & \multicolumn{2}{c}{\textbf{Election Day In-Person}}\\"
	noisily dis " & \multicolumn{2}{c}{Pr(Voted)[0-100\%]} & \multicolumn{2}{c}{Pr(Absentee)[0-100\%]} & \multicolumn{2}{c}{Pr(Early)[0-100\%]} & \multicolumn{2}{c}{Pr(Elec. Day)[0-100\%]} \\[2mm]"
	noisily dis " & (1) & (2) & (3) & (4) & (5) & (6) & (7) & (8) \\"
	noisily dis "\midrule"
	noisily dis "No-Excuse (Age=65) $\times$ 2020 & " %5.2f `b1' " & " %5.2f `b2' " & " %5.2f `b3' " & " %5.2f `b4' " & " %5.2f `b5' " & " %5.2f `b6' " & " %5.2f `b7' " & " %5.2f `b8' " \\"
	noisily dis " & (" %3.2f `se1' ") & (" %3.2f `se2' ") & (" %3.2f `se3' ") & (" %3.2f `se4' ") & (" %3.2f `se5' ") & (" %3.2f `se6' ") & (" %3.2f `se7' ") & (" %3.2f `se8' ") \\[2mm]"
	noisily dis " \# Obs & " %12.0fc `n1' " & " %12.0fc `n2' " & " %12.0fc `n3' " & " %12.0fc `n4' " & " %12.0fc `n5' " & " %12.0fc `n6' " & " %12.0fc `n7' " & " %12.0fc `n8' " \\"
	noisily dis " Year FE & Y & N & Y & N & Y & N & Y & N \\"
 	noisily dis " County-by-Year FE & N & Y & N & Y & N & Y & N & Y \\"
 	noisily dis " Age FE & Y & N & Y & N & Y & N & Y & N \\"
	noisily dis " County-by-Age FE & N & Y & N & Y & N & Y & N & Y \\"
	noisily dis "\bottomrule \bottomrule"
	noisily dis "\multicolumn{9}{p{1.3\textwidth}}{\footnotesize Robust standard errors in parentheses. "
	noisily dis "Unit of observation is an individual by year. Texans aged 64 or younger who are eligible to vote"
	noisily dis " must provide a valid excuse if they wish to vote absentee. Those aged 65 or older who are eligible to vote can vote absentee without an excuse.}"
	noisily dis "\end{tabular}}"
	noisily dis "\end{table}"
	
	log off

}







